﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace CC.Yacht
{
    [DataContract, KnownType(typeof(GameState))]
    public class Game : IComparable<Game>, IEquatable<Game>
    {
        #region Constructor
        public Game() : this(Guid.NewGuid())
        {
            // Empty constructor
        }

        public Game(Guid gameId)
        {
            GameId = gameId;
            IsStarted = false;
            Players = new List<User>();
        }
        #endregion

        #region Public Properties
        [DataMember]
        public Guid GameId { get; set; }

        [DataMember]
        public bool IsStarted { get; set; }

        [DataMember]
        public User Owner { get; set; }

        [DataMember]
        public List<User> Players { get; set; }
        #endregion

        #region Public Methods
        public int CompareTo(Game other)
        {
            int returnValue = -1;

            if (other != null)
            {
                returnValue = GameId.CompareTo(other.GameId);
            }

            return returnValue;
        }

        public bool Equals(Game other)
        {
            bool returnValue = false;

            if (other != null)
            {
                returnValue = (GameId == other.GameId);
            }

            return returnValue;
        }
        #endregion
    }
}
